<template>
  <div>
    <h1>调房表</h1>
  </div>
  <el-form ref="sizeFormRef" :model="sizeForm" :rules="seRules" label-width="80px" size="mini">
    <el-form-item label="电话号码">
      <el-input v-model="sizeForm.num"></el-input>
    </el-form-item>
    <el-form-item label="部门">
      <el-input v-model="sizeForm.department"></el-input>
    </el-form-item>
    <el-form-item label="职称">
      <el-input v-model="sizeForm.professional"></el-input>
    </el-form-item>
    <el-form-item label="家庭人口">
      <el-input v-model="sizeForm.population"></el-input>
    </el-form-item>
    <el-form-item label="原住房面积">
      <el-input v-model="sizeForm.area"></el-input>
    </el-form-item>
    <el-form-item label="原房号">
      <el-input v-model="sizeForm.onum"></el-input>
    </el-form-item>
    <el-form-item label="要求调房面积">
      <el-input v-model="sizeForm.rarea"></el-input>
    </el-form-item>
    <div class="u_submit">
      <el-button @click="submit" type="primary" plain>提交</el-button>
    </div>
  </el-form>
</template>

<script>
export default {
    data() {
      return {
        sizeForm: {
          num: '',
          department:'',
          professional:'',
          population:'',
          area:'',
          onum:'',
          rarea:''
        },
        seRules: {
        num: [
          {
            required: true,
            message: "请输入电话号码",
            trigger: "blur",
          },
        ],
        department: [
          {
            required: true,
            message: "请输入部门名",
            trigger: "blur",
          },
        ],
        professional: [
          {
            required: true,
            message: "请输入职称",
            trigger: "blur",
          },
        ],
        population: [
          {
            required: true,
            message: "请输入家庭人口数",
            trigger: "blur",
          },
        ],
        area: [
          {
            required: true,
            message: "请输入原住房面积",
            trigger: "blur",
          },
        ],
        onum: [
          {
            required: true,
            message: "请输入原房号",
            trigger: "blur",
          },
        ],
        rarea: [
          {
            required: true,
            message: "要求调房面积",
            trigger: "blur",
          },
        ],
      },
      };
    },
    methods: {
      submit(){
        this.$refs.sizeFormRef.validate(async(valid)=>{
          if(!valid)return;
          const{data:res}=await this.$http.post(
            "api/auth/reapply",
            this.sizeForm
          );
          if(res.code==2000){
            this.$message.error("手机号码输入错误，请重新输入");
            return;
          }
           if(res.code==2001){
            this.$message.error("职称不能为空");
            return;
          }
           if(res.code==2002){
            this.$message.error("家庭人口数不能为空");
            return;
          }
           if(res.code==2003){
            this.$message.error("部门不能为空");
            return;
          }
           if(res.code==2004){
            this.$message.error("要求原住房面积不能为空");
            return;
          }
          if(res.code==2005){
            this.$message.error("要求原房号不能为空");
            return;
          }
          if(res.code==2006){
            this.$message.error("要求调房面积不能为空");
            return;
          }
          if (res.code == 200) {
          this.$message.success("提交成功");
          //this.$router.push({ path:"/adminhome"});
          return;
        }
         this.$message.error("后台错误");
        });
      }
       },
  };
</script>
<style lang="less" scoped>
.u_submit {
  position: absolute;
  left: 600px;
}
</style>